package me.xplabs.view 
{
	import flash.display.Bitmap;
	import flash.display.DisplayObjectContainer;
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import me.xplabs.constant.SceneType;
	import me.xplabs.Globals;
	import me.xplabs.msg.NotificationName;
	import me.xplabs.ui.baseui.Button;
	import me.xplabs.ui.baseui.Label;
	import me.xplabs.ui.BaseView;
	import me.xplabs.ui.UICompent;
	
	/**
	 * 游戏失败了界面
	 * http://www.xplabs.me/
	 * @author xiaohan
	 */
	public class FailGameView extends BaseView
	{
		private var _backGroundBitmap:Bitmap;
		private var _tryAgainBtn:Button;
		private var _quitBtn:Button;
		private var _contentLabel:Label;
		
		
		//private var _sprite:Sprite;
		//private var _mask:Shape;
		
		public function FailGameView(pfather:DisplayObjectContainer) 
		{
			super(pfather);
		}
		override protected function init():void 
		{
			super.init();
			
			//_container.visible = false;
			//_sprite = new Sprite();
			//addChild(_sprite);
			
			_backGroundBitmap = new Bitmap();
			_backGroundBitmap.bitmapData = Globals.lib.getResObj(Globals.domain.texture + "26");
			addChild(_backGroundBitmap);
			
			
			_tryAgainBtn = Globals.ui.button("", 9);
			_tryAgainBtn.x = 195;
			_tryAgainBtn.y = 336;
			addChild(_tryAgainBtn);
			_tryAgainBtn.callback = clickTryAgainHandler;
			
			
			_quitBtn = Globals.ui.button("", 7);
			_quitBtn.x = 400;
			_quitBtn.y = 350;
			addChild(_quitBtn);
			_quitBtn.callback = clickQuitHandler;
			
			
			_contentLabel = Globals.ui.label("你失败了！！");
			addChild(_contentLabel);
			_contentLabel.color = 0x000000;
			_contentLabel.x = 194;
			_contentLabel.y = 218;
			pw = _container.width;
			ph = _container.height;
			maskEnabled = true;
			
			//UICompent.addListener(_tryAgainBtn);
			//UICompent.addListener(_quitBtn);
			//UICompent.addListener(_contentLabel);
		}
		
		private function clickQuitHandler(e:MouseEvent):void 
		{
			sendMsg(NotificationName.HIDE_END_GAME);
			sendMsg(NotificationName.CHANGE_SCENE, SceneType.SELECT_SCENE);
		}
		
		private function clickTryAgainHandler(e:MouseEvent):void 
		{
			sendMsg(NotificationName.HIDE_END_GAME);
			sendMsg(NotificationName.TRY_ANGIN_GAME);
		}
	}

}